<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>
<html>
 <head>
    <title>调拨管理</title>
	<%@ include file="/common/meta.jsp" %>
	<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript">
		var basic_Url="${ctx}/logic/allocation";
		var basic_WUrl="logic/allocation";
		var basic_Title="调拨管理";
		var show_Width=950;
		var show_Hight=400;
		var user='${user.name}';
		function createSearch(){
			init(1,10,'80,100,80,100,80,100,80,100,80,100','25%');
			//第一行的数据
			addCommon(0,0,"lable","发起单号");
			addCommon(0,1,"txtlike","zd001Code");
			addCommon(0,2,"lable","出库仓库：");
			addCommon(0,3,"selectEnum","zd003OutWhCode","<option></option><c:forEach var="s" items="${ouwhList}"><option value='${s.zd002Code}'>${s.zd003Name}</option></c:forEach>");
			addCommon(0,4,"lable","入库仓库：");
			addCommon(0,5,"selectEnum","zd004InWhCode","<option></option><c:forEach var="s" items="${inwhList}"><option value='${s.zd002Code}'>${s.zd003Name}</option></c:forEach>");
			addCommon(0,6,"lable","单据状态：");
			addCommon(0,7,"selectEnum","zd002Status","<option></option><option value='ACT_SAVE'>草稿</option>"+
					"<option value='ACT_SUBMIT'>已提交</option><option value='ACT_AUDIT'>完成</option><option value='ACT_BACK'>驳回</option>");
		}
		function searchAP(){			
			multipleSearch("#table1",true,"",basic_Url+"/list.do");
		}
		$(function(){
			var grid = $("#table1").ligerGrid({
		        columns: [{ display: 'id', name: 'id', hide : true},
		                  { display: '调拨单号', name: 'zd001Code', width: 150 ,isSort:false},
		                  { display: '出库仓库', name: 'zd003OutWhName', width: 150,isSort:false},
		                  { display: '入库仓库', name: 'zd004InWhName', width: 150,isSort:false},
		                  { display: '单据状态',name: 'zd002Status', width: 140,isSort:false,
		                		render : function(item){
			                		if (item.zd002Status == 'ACT_SAVE'){
			                			return "草稿";
			                		}else if (item.zd002Status == 'ACT_SUBMIT'){
			                			return "已提交";
			                		}else if (item.zd002Status == 'ACT_AUDIT'){
			                			return "完成";
			                		}else if (item.zd002Status == 'ACT_BACK'){
			                			return "驳回";
			                		}
		                		}  
		                  },
		                  { display: '出库时间', name: 'zd005OutDate', width: 120,isSort:false,
		                	  render: function (item){
		                		  var mvDate=new Date(item.zd005OutDate);
		                		  return formatDate(mvDate,"yyyy-MM-dd");
		                	  }
		                  },
		                  { display: '制单人', name: 'zd007Aegnt', width: 100,isSort:false },
		                  { display: '备注', name: 'zd008Remark', width: 150,isSort:false}
		                  ],  usePager: true,pageSize:15,
		                      url : basic_Url+"/list.do",
		                      width: '100%', height: '98%',pageSizeOptions :[15,25,35], checkbox: true,rownumbers:true,
		                      onDblClickRow : function (data, rowindex, rowobj){
		                          edit(data);
		                       }
		                  });
			$("#pageloading").hide();
		});
		function checkdel(){
			var manager = $("#table1").ligerGetGridManager(); 
			var rows = manager.getSelectedRows();
			var bol = false;
			if (rows==null){
				$.dialog.alert('请选择需要操作删除的行！');
				return;
			}else{
				for(var i=0;i<rows.length;i++){
				 	if (rows[i].bizCreatorName !='${user.name}'){
				 		bol = true;
					}
				}
				if(bol){
					$.dialog.alert('只能对本人建的单据进行删除操作!');
					return;
				}else{
					bol = false;
					for(var i=0;i<rows.length;i++){
					 	if (rows[i].zd002Status == 'ACT_SAVE'||rows[i].zd002Status=='ACT_BACK'){
					 		bol = true;
						}
					}
					if(bol){
						del();
						bol = false;
					}else{
						$.dialog.alert('草稿状态的单据才能进行删除!');
						return;
					}
				}
			}
			
		}
	</script>
  </head>
<body onLoad="createSearch()">
   <div id="layout1">
      <div position="top">
          <div class="panelBar">
	           <ul class="toolBar">
	             
		           <li><a class="add" onclick="add()">
		           <span>添加</span></a></li>
				   <li><a class="delete" onclick="checkdel()"><span>删除</span></a></li>
               </ul>
          </div>
          <div id="pageHeader" class="pageHeader">
               <div class="searchBar" id="multipleSearchDialog">
	                <table class="table" width="100%" id="searchHeader" >  
                        <tbody id="newbody">
                        </tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               </div>
          </div>
      </div>
      <div position="center" id="table1">
      </div>
      <div class="clear"></div>
   </div>
 
</body>
</html>